﻿namespace Leetcode.N1823;
public class Solution
{
    public int FindTheWinner(int n, int k)
    {
        var list = new List<int>(n);
        for (int i = 1; i <= n; i++)
        {
            list.Add(i);
        }
        int fromIndex = 0;
        while (list.Count > 1)
        {
            fromIndex = (fromIndex + k - 1) % list.Count;
            list.RemoveAt(fromIndex);

        }
        return list[0];
    }
}